<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title><s:if test="category.categoryId==null"><s:text name="category.add.title"/></s:if><s:else><s:text name="category.edit.title"/></s:else></title>
	<%@ include file="/common/meta.jsp"%>
	<%@ include file="/common/common.jsp"%>
</head>
<body>
<s:set name="siteId" value="#session['CURRENT_SITE'].siteId"></s:set>
<div id="wrapper">
	<div class="curmb"><s:text name="your.site.position"/>:<a href="${ctx}/welcome.action"><s:text name="homepage"/></a><span>></span><s:text name="category.title"/></div>
	<div class="listtit"><p><span><strong><s:if test="category.categoryId==null"><s:text name="category.add.title"/></s:if><s:else><s:text name="category.edit.title"/></s:else></strong></span></p></div>
	<div class="listadd">
		<s:hidden name="category.catName" id="catname"/>
		<s:hidden name="category.catSimpleName" id="catSimplename"/>
		<s:form action="category-save" onsubmit="return chkform()">
		<s:hidden name="category.category.categoryId" id="parentCategoryId"/>
		<s:hidden name="category.categoryId" id="categoryId"/>
		<s:hidden name="isAudit" id="isAudit"/>
		<s:hidden name="category.site.siteId"/>
		<div class="listoperate" id="listoperate">
	    <span class="space20"></span>
		     <a href="#" id="basic" class="alinkscurrent"><s:text name="基本信息"/></a>|
		     <a href="#" id="attachConfig" class="alinks"><s:text name="附件配置" /> </a>
		</div>
		<table class="addgrid" id="bs">
			<tr id="parentCat">
				<s:if test="category.category.catName != null">
					<th><s:text name="category.cmsCategory"/>:</th>
					<td  colspan="3">
						<s:textfield id="parentCatName" name="category.category.catName" required="true" requiredposition="right" cssClass="txtin" readonly="true"/>
					</td>
				</s:if>
			</tr>
			<tr>
				<th><s:text name="category.catName"/>:</th>
				<td>
					<s:textfield id="cateName" name="category.catName" required="true" maxlength='20'  requiredposition="right" cssClass="txtin" onkeyup="check()"/>
					<span id="point-catName-Message" style="color: red;">*</span>
					<span id="catPointMessage" ></span>
				</td>
				<th><s:text name="category.catSimpleName"/>:</th>
				<td><s:textfield id="simName" name="category.catSimpleName" required="true" maxlength='20'  requiredposition="right" cssClass="txtin"  onblur="checkSimpName()" />
					<span style="color: red">*</span><span id="point-catSimpleName-Message" style="color: #457d07"><br/>(友情提示:只能输入20个由小写字母、数字、下划线组成的字符)</span>
					<span id="simPointMessage"></span>
				</td>
				
			</tr>
			<tr>
				<th><s:text name="category.isComment"/>:</th>
				<td>
					<s:if test="dicIsComment!=null && category.categoryId!=null">
							<s:radio name="category.isComment" list="dicIsComment" listKey="dictionaryKey" listValue="dictionaryValue" 
							value="category.isComment" />
					</s:if>
					<s:elseif test="dicIsComment!=null && category.categoryId==null">
						<s:radio name="category.isComment" list="dicIsComment" listKey="dictionaryKey" listValue="dictionaryValue" 
							value="true"/>
					</s:elseif>
				</td>
				<th><s:text name="category.isInitComment"/>:</th>
				<td>
				 <s:if test="dicIsInitcomment!=null && category.categoryId!=null" >
							<s:radio name="category.isInitComment" list="dicIsInitcomment" listKey="dictionaryKey" listValue="dictionaryValue" 
							value="category.isInitComment" />
				 </s:if>
				 <s:elseif test="dicIsInitcomment!=null">
				 	<s:radio name="category.isInitComment" list="dicIsInitcomment" listKey="dictionaryKey" listValue="dictionaryValue" 
							value="true" />
				 </s:elseif>
				</td>
			</tr>
			<tr>
				<th><s:text name="category.isAudit"/>:</th>
				<td>
					<s:if test="dicIsAudit!=null && category.categoryId!=null">
							<s:radio name="category.isAudit" list="dicIsAudit" listKey="dictionaryKey" listValue="dictionaryValue" 
							value="category.isAudit" id="auDit"/>
					</s:if>
					<s:elseif test="dicIsAudit!=null && category.categoryId==null">
						<s:radio name="category.isAudit" list="dicIsAudit" listKey="dictionaryKey" listValue="dictionaryValue" 
							value="true" id="auDit"/>
					</s:elseif>
				</td>
				<th><s:text name="category.isContribute"/>:</th>
				<td>
				  <s:if test="dicIsContribute!=null && category.categoryId!=null">
							<s:radio name="category.isContribute" list="dicIsContribute" listKey="dictionaryKey" listValue="dictionaryValue" 
							value="category.isContribute" />
				  </s:if>
				  <s:elseif test="dicIsContribute!=null && category.categoryId==null">
				  	<s:radio name="category.isContribute" list="dicIsContribute" listKey="dictionaryKey" listValue="dictionaryValue" 
							value="true" />
				  </s:elseif>
				</td>
			</tr>
			<tr>
				<th><s:text name="category.isLink"/>:</th>
				<td >
					<s:if test="dicIsLink!=null && category.categoryId!=null">
							<s:radio name="category.isLink" list="dicIsLink" listKey="dictionaryKey" listValue="dictionaryValue" 
							value="category.isLink" />
				  </s:if>
				  <s:elseif test="dicIsLink!=null && category.categoryId==null">
				  	<s:radio name="category.isLink" list="dicIsLink" listKey="dictionaryKey" listValue="dictionaryValue" 
							value="true" />
				  </s:elseif>
				</td>
				<th>页面树是否链接到首页:</th>
				<td >
					<s:if test="dicIsContribute!=null && category.categoryId!=null">
							<s:radio name="category.treeIndexLink" list="dicIsLink" listKey="dictionaryKey" listValue="dictionaryValue" 
							value="category.treeIndexLink" />
				  </s:if>
				  <s:elseif test="dicIsContribute!=null && category.categoryId==null">
				  	<s:radio name="category.treeIndexLink" list="dicIsLink" listKey="dictionaryKey" listValue="dictionaryValue" 
							value="true" />
				  </s:elseif>
				</td>
			</tr>
			<tr>
				<th><s:text name="category.catIndexTpl"/>:</th>
				<td>
					<s:textfield name="category.catIndexTpl" id="selectIndex" required="true" requiredposition="right" cssClass="txtin" readonly="true"/>
					<a href="javascript:selectIndex()"><s:text name="choice"/></a>
					<span id="point-catName-Message" style="color: red;">*</span>
					<span id="indexPointMessage"></span>
				</td>
				<th><s:text name="category.catContentListTpl"/>:</th>
				<td>
					<s:textfield name="category.catContentListTpl" id="catContentListTpl" required="true" requiredposition="right" cssClass="txtin" readonly="true" />
					<a href="#"  onclick="contentListTpl()"><s:text name="choice"/></a>
					<span id="point-catName-Message" style="color: red;">*</span>
					<span id="listPointMessage"></span>
				</td>
			</tr>
			<tr>
				<th><s:text name="category.catDefaultContentTpl"/>:</th>
				<td>
					<s:textfield name="category.catDefaultContentTpl" id="catDefaultContentTpl" required="true" requiredposition="right" cssClass="txtin" readonly="true" />
					<a href="#"  onclick="defaultContentTpl()"><s:text name="choice"/></a>
					<span id="point-catName-Message" style="color: red;">*</span>
					<span id="defaultPointMessage"></span>
				</td>
				<th><s:text name="category.catContentTplSet"/>:</th>
				<td>
					<s:textfield name="category.catContentTplSet" id="catContentTplSet" required="true" requiredposition="right" cssClass="txtin" readonly="true" />
					<a href="#"  onclick="contentTplSet()"><s:text name="choice"/></a>
					<span id="point-fsdfName-Message" style="color: red;">*</span>
					<span id="contPointMessage"></span>
				</td>
			</tr>
			<tr>
				<th><s:text name="category.catContentPhotoAlert"/>:</th>
				<td>
					<s:textarea id="catContentPhotoAlert" onkeyup="checkPhotoAlertNum()" name="category.catContentPhotoAlert" cssStyle="height:80px;overflow-y:visible;" maxlength='100' required="true" requiredposition="right" cssClass="txtin"></s:textarea>
				</td>
				<th><s:text name="category.catContentTitleAlert"/>:</th>
				<td>
					<s:textarea id="catContentTitleAlert" onkeyup="checkTitleAlertNum()" name="category.catContentTitleAlert" cssStyle="height:80px;overflow-y:visible;" maxlength='100' required="true" requiredposition="right" cssClass="txtin"></s:textarea>
				</td>
			</tr>
			<tr id="auditor" style="display: none"> 
				<th><s:text name="category.auditor"/>:</th>
				<td colspan="3"><s:textfield id="showAuthor" name="category.auditor" required="true" requiredposition="right" cssClass="txtin" readonly="true"/>
				<a href="#" id="authorSelect" onclick="authorSelect()"><s:text name="choice"/></a></td>
			</tr>
			<tr id="createMessageOne">
				<th><s:text name="category.createTime"/>:</th>
				<td><input type="text" name="category.createTime" value="<s:date name="category.createTime" format="yyyy-MM-dd HH:mm:ss"/>" class="txtin unable" readonly="readonly"/></td>
				<th><s:text name="category.createLoginName"/>:</th>
				<td><s:textfield name="category.createLoginName" required="true" requiredposition="right" cssClass="txtin unable" readonly="true"/></td>
			</tr>
			<tr id="createMessageTwo">
				<th><s:text name="category.createRealName"/>:</th>
				<td><s:textfield name="category.createRealName" required="true" requiredposition="right" cssClass="txtin unable" readonly="true"/></td>
				<th><s:text name="category.updateTime"/>:</th>
				<td><input type="text" name="category.updateTime" value="<s:date name="category.updateTime" format="yyyy-MM-dd HH:mm:ss"/>" class="txtin unable" readonly="readonly"/></td>
			</tr>
			<tr id="createMessageThree">
				<th><s:text name="category.updateLoginName"/>:</th>
				<td><s:textfield name="category.updateLoginName" required="true" requiredposition="right" cssClass="txtin unable" readonly="true"/></td>
				<th><s:text name="category.updateRealName"/>:</th>
				<td><s:textfield name="category.updateRealName" required="true" requiredposition="right" cssClass="txtin unable" readonly="true"/></td>
			</tr>
			<tr id="categoryStatus">
				<th><s:text name="categoryStatus"/>:</th>
				<td  colspan="3">
					<s:if test="category.categoryStatus == 1"><s:text name="yetEnable"/></s:if><s:else><s:text name="yetDisable"/></s:else>
				</td>
			</tr>
			
		</table>
		<table class="addgrid" id="at" style="display: none">
			<tr>
				<td align="center"><s:text name="配置项"/></th>
				<td align="center"><s:text name="参数值"/></th>
			</tr>
			<tr>
				<th><s:text name="小图片尺寸"/>:</th>
				<td>
					<s:textfield  name="category.smallPictureSize" required="true" maxlength='64'  requiredposition="right" cssClass="txtin" onkeyup="check()"/>
					<span style="color: #457d07">(高和宽用下划线隔开，例：137_83 )</span>
				</td>
			</tr>
			<tr>
				<th><s:text name=" 中图片尺寸"/>:</th>
				<td>
					<s:textfield   name="category.middlePictureSize" required="true" maxlength='64'  requiredposition="right" cssClass="txtin" onkeyup="check()"/>
					<span style="color: #457d07">(高和宽用下划线隔开，例：137_83 )</span>
				</td>
			</tr>
			<tr>
				<th><s:text name="大图片尺寸"/>:</th>
				<td>
					<s:textfield   name="category.bigPictureSize" required="true" maxlength='64'  requiredposition="right" cssClass="txtin" onkeyup="check()"/>
					<span style="color: #457d07">(高和宽用下划线隔开，例：137_83 )</span>
				</td>
			</tr>
			<tr>
				<th><s:text name="图片类型"/>:</th>
				<td>
					<s:textfield   name="category.picType" required="true" maxlength='64'  requiredposition="right" cssClass="txtin" onkeyup="check()"/>
					<span style="color: #457d07">(类型之间用 | 隔开，例：jpg|gif|png )</span>
				</td>
			</tr>
			<tr>
				<th><s:text name="动画类型"/>:</th>
				<td>
					<s:textfield   name="category.cartoonType" required="true" maxlength='64'  requiredposition="right" cssClass="txtin" onkeyup="check()"/>
					<span style="color: #457d07">(类型之间用 | 隔开，例：swf|mpg |rm|rmvb|wmv|wma|wav|mid|mov )</span>
				</td>
			</tr>
			<tr>
				<th><s:text name="视频类型"/>:</th>
				<td>
					<s:textfield   name="category.videoType" required="true" maxlength='64'  requiredposition="right" cssClass="txtin" onkeyup="check()"/>
					<span style="color: #457d07">(类型之间用 | 隔开，例：swf|mpg |rm|rmvb|wmv|wma|wav|mid|mov )</span>
				</td>
			</tr>
			<tr>
				<th><s:text name="软件类型"/>:</th>
				<td>
					<s:textfield   name="category.softWareType" required="true" maxlength='64'  requiredposition="right" cssClass="txtin" onkeyup="check()"/>
					<span style="color: #457d07">(类型之间用 | 隔开，例：exe|iso|zip|7z|rar|gz )</span>
				</td>
			</tr>
			<tr>
				<th><s:text name="图片附件大小控制"/>:</th>
				<td>
					<s:textfield   name="category.pictureAdvice" required="true" maxlength='11'  requiredposition="right" cssClass="txtin" onkeyup="this.value=this.value.replace(/\D/g,'')" />
					<span style="color: #457d07">(M)</span> <span style="color: #457d07">(最多只能输入11位的数字 )</span>
				</td>
			</tr>
			<tr>
				<th><s:text name="动画附件大小控制"/>:</th>
				<td>
					<s:textfield   name="category.cartoonAdvice" required="true" maxlength='11'  requiredposition="right" cssClass="txtin" onkeyup="this.value=this.value.replace(/\D/g,'')" />
					<span style="color: #457d07">(M)</span> <span style="color: #457d07">(最多只能输入11位的数字 )</span>
				</td>
			</tr>
			<tr>
				<th><s:text name="视频附件大小控制"/>:</th>
				<td>
					<s:textfield   name="category.videoAdvice" required="true" maxlength='11'  requiredposition="right" cssClass="txtin" onkeyup="this.value=this.value.replace(/\D/g,'')" />
					<span style="color: #457d07">(M)</span> <span style="color: #457d07">(最多只能输入11位的数字 )</span>
				</td>
			</tr>
			<tr>
				<th><s:text name="软件附件大小控制"/>:</th>
				<td>
					<s:textfield   name="category.softwareAdvice" required="true" maxlength='11'  requiredposition="right" cssClass="txtin" onkeyup="this.value=this.value.replace(/\D/g,'')" />
					<span style="color: #457d07">(M)</span> <span style="color: #457d07">(最多只能输入11位的数字 )</span>
				</td>
			</tr>
		</table>
		<table>
			<tr>
				<th>&nbsp;</th>
				<td colspan="3">
				<s:if test="%{authLicence('2_2_2',#siteId)}">
					<s:submit value="%{getText('save')}" cssClass="btnlist2" id="save_button" disabled="true"/>			 
				</s:if>
				<s:elseif test="%{authLicence('3_3_1',category.category.categoryId)}">
					<s:submit value="%{getText('save')}" cssClass="btnlist2"/>		
				</s:elseif>
				<s:else>
					<s:submit disabled="true" value="%{getText('save')}" cssClass="btnlist2"/>
				</s:else>
				<span style="color: #457d07">(请先正确填写栏目基本信息)</span>
				<%-- <s:reset type="button"  value="%{getText('reset')}" onclick="reSet()" cssClass="btnlist2"/> --%>
				<s:reset value="%{getText('returnflag')}"  onclick="goBack()" cssClass="btnlist2"/></td>
			</tr>
		</table>
		</s:form>
	</div>
</div>
<div id="lightbox" class="lightbox">
	<div class="lighttit"><p><span><input type="button" value="&nbsp;" id="lightclose" class="lightclose" /><strong><s:text name="authorSet"/></strong></span></p></div>
	<div class="lightmain">
		<div class="lightmaintit"><s:text name="choice"/><s:text name="auditRealName"/></div>
		<div class="ilghtmainbox">
			<div id="authorSetDiv"></div>
		</div>
		<div class="lightbtnbox"><input type="button" value="<s:text name="save"/>" id="lightsubmit" class="btnlist2" onclick="authorSet()"/><input type="button" id="closebtn" value="<s:text name="取消"/>"  class="btnlist2" /></div>
	</div>
</div>
<script type="text/javascript">
$("#authorSelect").bind("click",function(){
	$$.shade("#authorSelect","#lightclose,#closebtn,#lightsubmit","#lightbox");
});
</script>
</body>
</html>
<script type="text/javascript" defer="defer">
	var parentCategoryId = $("#parentCategoryId").val();
	var categoryId = $("#categoryId").val();
	var isUni="no";
	function chkform(){
	 	var cName = $("#cateName").val();
	 	var cateName = cName.replace(/(^\s*)|(\s*$)/g, "");
	 	var sName = $("#simName").val();
	 	var simName = sName.replace(/(^\s*)|(\s*$)/g, "");
	 	var catIndexTpl = $("#selectIndex").val();
	 	var catContentListTpl = $("#catContentListTpl").val();
	 	var catDefaultContentTpl= $("#catDefaultContentTpl").val();
	 	var catContentTplSet= $("#catContentTplSet").val();
	 	
		if(cateName.trim() == null || cateName.trim() == "" ){
			$("#catPointMessage").css("color","red");
			$("#catPointMessage").html("栏目名称不能为空");
			return false;
		} 
		if(isUni == "have"){
			return false;
		}
		var simPointMessage=$("#simPointMessage").val();
		 if(simPointMessage=="ok"){
			return false;
		}
		 //判断模板是否为空
		  	var selectIndex = $("#selectIndex").val();
		  	if(selectIndex == null || selectIndex == ""){
		  		$("#indexPointMessage").css("color","red");
		  		$("#indexPointMessage").html("不能为空");
		  		return false;
		  	}else{
		  		$("#indexPointMessage").html("");
		  	}
		  	var catContentListTpl = $("#catContentListTpl").val();
			if(catContentListTpl == null || catContentListTpl == ""){
				$("#listPointMessage").css("color","red");
		  		$("#listPointMessage").html("不能为空");
		  		return false;
		  	}else{
		  		$("#listPointMessage").html("");
		  	}
		  	var catDefaultContentTpl = $("#catDefaultContentTpl").val();
			if(catDefaultContentTpl == null || catDefaultContentTpl == ""){
				$("#defaultPointMessage").css("color","red");
		  		$("#defaultPointMessage").html("不能为空");
		  		return false;
		  	}else{
		  		$("#defaultPointMessage").html("");
		  	}
		  	var catContentTplSet = $("#catContentTplSet").val();
			if(catContentTplSet == null || catContentTplSet == ""){
				$("#contPointMessage").css("color","red");
		  		$("#contPointMessage").html("不能为空");
		  		return false;
		  	}else{
		  		$("#contPointMessage").html("");
		  	}
			var simNameCheck=/^[a-z0-9_]+$/;
			var simName=$("#simName").val();
			if(!simNameCheck.test(simName)){
				$("#point-catSimpleName-Message").html("只能输入20个由小写字母、数字、下划线组成");
				$("#point-catSimpleName-Message").css("color","red");
				return false;
			}
			
			var sh = $('input[name=category.isAudit]:checked').val();
			if(sh == false){
				$("#showAuthor").val("");
			}
	}
	
	//输入1秒后检测用户名
	 var timer = false;
	 var fla = "no";
	 function check() {
		
	  	 if (timer) {
           clearTimeout(timer);
           timer = false;
	      }
	 	 timer = setTimeout(function () {
			   checkUniName();
		  }, 1000);
	}
	
	 //鼠标离开时检测栏目简称是否合法
	 function checkSimpName(){
		 var simNameCheck=/^[a-z0-9_]+$/;
			var simName=$("#simName").val();
			if(!simNameCheck.test(simName)){
				$("#point-catSimpleName-Message").html("只能输入20个由小写字母、数字、下划线组成");
				$("#point-catSimpleName-Message").css("color","red");
				return false;
			}
	 }
	 
	 //唯一检测，如果用户名不为空进行数据库校验
	function checkUniName(){

		var catname =  $("#catname").val();//old 
		var cateName = $("#cateName").val();//xin
			if(cateName != null && cateName != ""){
				var obj = {"category.catName":cateName,"category.category.categoryId":parentCategoryId,"catname":catname};
				$.post("${ctx}/category/category-checknameunique.action",obj,function(data){
			
					if(data == "ok"){
						$("#catPointMessage").css("color","#457d07");
						$("#catPointMessage").html("栏目名可用");
						isUni = "no";
						return true;
					}else{
						$("#catPointMessage").css("color","red");
						$("#catPointMessage").html("栏目名已经被占用，请重新输入");
						isUni = "have";
						return false;
					}
			 });
		}
	}
	
 
	
	//判断：如果是添加页面，隐藏相关信息
	var categoryId = $("#categoryId").val();
	if(categoryId == null || categoryId == ""){
		$("#createMessageOne").hide();
		$("#createMessageTwo").hide();
		$("#createMessageThree").hide();
		$("#parentCat").hide();
		$("#categoryStatus").hide();
	}
	//编辑时判断是否显示审核人
	if(categoryId != null && categoryId != ""){
		auDit();
	}
	
	//判断是否隐藏审核人
	function auDit(){
		var sh = $('input[name=category.isAudit]:checked').val();
		if(sh=='true'){
			$("#auditor").show();
		}else{
			$("#auditor").hide();
		}
	}
	$(function(){
		$("input[name=category.isAudit]").change(auDit);
	});
	
	//审核人设置-选择审核人
	function authorSelect(categoryId){
		$.getJSON("${ctx}/category/category-authorsetselect.action",function(data){
			var htmlStr = "";
			var authorArray = new Array(data.length);
			for(var i=0;i<data.length;i++){
				var adminId = data[i].adminId;
				var loginName = data[i].loginName;
				var realName=data[i].realName;
				if(realName==null){
					authorArray[i]="<li><input name=\"autor\" onclick=\"authorSet()\" type='checkbox' value='"+loginName+"'>&nbsp;<a id='siteStatus"+i+"'>"+loginName+"</a></li>";
				}else{
					authorArray[i]="<li><input name=\"autor\" onclick=\"authorSet()\" type='checkbox' value='"+loginName+"'>&nbsp;<a id='siteStatus"+i+"'>"+loginName+"</a>&nbsp;&nbsp;<a id='realName"+i+"'>"+realName+"</a></li>";
				}		
			}
			htmlStr = authorArray.join("");
			$("#authorSetDiv").html("<ul id='shenheul'>"+htmlStr+"</ul>");
			
			
			//回显已经选中的审核人
			var author = $("#showAuthor").val();
			var  authors = author.split(",");
			$("input[name='autor']").each(function(i){
					for(var i=0;i<authors.length;i++){
						if($(this).attr("value")==authors[i]){
							$(this).attr("checked",true);
						}
					}
			});
		});
	}
	
	//审核人设置-添加到审核人文本框
	function authorSet(adminName,categoryId){
		 var arr = new Array();
			$("#authorSetDiv").find('input:checkbox[name="autor"]:checked').each(function(i,item){
				 var s = $(item).val();
				 arr.push(s);
			});
		    var  str = arr.join(',');
		 $("#showAuthor").val(str);
	}
	
	//新增栏目时设置默认模板
	if(categoryId == null || categoryId == ""){
		/* $("#selectIndex").val("/theme/default/cat/style1/index.tpl");
		$("#catContentListTpl").val("/theme/default/cat/style1/list.tpl");
		$("#catDefaultContentTpl").val("/theme/default/content/style1/article/index.tpl");
		$("#catContentTplSet").val("/theme/default/content/style1/article/list.tpl"); */
	}
	
	
	//栏目首页模板
	function selectIndex(){
		if(categoryId != null && categoryId != ""){
			var selectIndex = $("#selectIndex").val();
			var url = "${ctx}/theme/file-select.action?type=cat&prefix=index&suffix=tpl&elementId=selectIndex&selected="+selectIndex; 
		}else{
			var url = "${ctx}/theme/file-select.action?type=cat&prefix=index&suffix=tpl&elementId=selectIndex&selected="+selectIndex;  
		}
		window.open(url); 
	}
	//栏目文章列表模板
	function contentListTpl(){
		var catContentListTpl = $("#catContentListTpl").val();
		var url = "${ctx}/theme/file-select.action?type=cat&prefix=list&suffix=tpl&elementId=catContentListTpl&selected="+catContentListTpl; 
		window.open(url); 
	}
	//栏目的默认文章模板
	function defaultContentTpl(){
		var catDefaultContentTpl = $("#catDefaultContentTpl").val();
		var url = "${ctx}/theme/file-select.action?contentType=article&prefix=content&suffix=tpl&elementId=catDefaultContentTpl&selected="+catDefaultContentTpl; 
		window.open(url); 
	}
	//栏目的可选文章模板
	function contentTplSet(){
		var catContentTplSet = $("#catContentTplSet").val();
		var url = "${ctx}/theme/file-select.action?contentType=article&prefix=content&suffix=tpl&elementId=catContentTplSet&selected="+catContentTplSet; 
		window.open(url); 
	}
	function goBack(){
		history.go(-1);
		//document.location.href="${ctx}/category/category-list.action";
	}
	
	var actionName = "category";
	//重置(保留原有的默认信息)
	function reSet(){
		goNewCate();
	}
	function goNewCate(){
		if(categoryId == null || categoryId == ""){
			goNew();
		}else{
			gonewChild();
		}
	}
	function gonewChild(){
		document.location.href=actionName+"-input.action?category.category.categoryId="+categoryId;
	}
 	$(function(){
 		var simName=$("#simName").val();
 		simName=$.trim(simName);
 		if(simName==""||simName==null){
 			document.getElementById("save_button").disabled = true;
 		}else{
 			document.getElementById("save_button").disabled = false;
 		}
		$("#simName").mouseout(function(){
			var oldsimName=$("input[name=category.catSimpleName]").val();
			var simName=$("#simName").val();
			var obj = {"category.catSimpleName":simName,"oldsimName":oldsimName};
			
			if(simName==""||simName==null){
				$("#point-catSimpleName-Message").html("栏目简称不能为空！");
				$("#point-catSimpleName-Message").css("color","red");
				$("#simPointMessage").val("ok");
				document.getElementById("save_button").disabled = true;
			}else{
				 var simNameCheck=/^[a-z0-9_]+$/;
					var simName=$("#simName").val();
					if(!simNameCheck.test(simName)){
						$("#point-catSimpleName-Message").html("只能输入20个由小写字母、数字、下划线组成");
						$("#point-catSimpleName-Message").css("color","red");
						return false;
					}
				$.post(
						 "${ctx}/category/category-checksimpleunique.action",obj,
						 function (data){
							if(data=="no"){
								$("#point-catSimpleName-Message").html("栏目简称已注册!");
								$("#point-catSimpleName-Message").css("color","red");
								$("#simPointMessage").val("ok");
								document.getElementById("save_button").disabled = true;
							}if(data=="ok"){
								$("#point-catSimpleName-Message").html("");
								$("#simPointMessage").val("no");
								document.getElementById("save_button").disabled = false;
							}					
						});
			}
			
		});
		
	}); 
 	//检测字数是否大于100
 	function checkPhotoAlertNum(){
		var catContentPhotoAlertlength = $("#catContentPhotoAlert").val().length;
		var catContentPhotoAlert = $("#catContentPhotoAlert").val();
		if(catContentPhotoAlertlength >100){
			var aa = catContentPhotoAlert.substring(0,100);
			$("#catContentPhotoAlert").val(aa);
		}
	}
 	function checkTitleAlertNum(){
 		var catContentTitleAlertlength = $("#catContentTitleAlert").val().length;
		var catContentTitleAlert = $("#catContentTitleAlert").val();
		if(catContentTitleAlertlength >100){
			var aa = catContentTitleAlert.substring(0,100);
			$("#catContentTitleAlert").val(aa);
		}
 	}
 	
 	//基本信息、附件配置信息切换
 	$("#attachConfig").click(function(){
 		$("#basic").removeClass("alinkscurrent").addClass("alinks");
 		$("#attachConfig").removeClass("alinks").addClass("alinkscurrent");
 		
 		$("#at").css("display",'block');
 		$("#bs").css("display",'none');
 		
 	})
 	$("#basic").click(function(){
 		$("#basic").removeClass("alinks").addClass("alinkscurrent");
 		$("#attachConfig").removeClass("alinkscurrent").addClass("alinks");
 	
 		$("#at").css("display",'none');
 		$("#bs").css("display",'block');
 	})
 	
 	if(categoryId == null || categoryId == ""){
 		document.getElementById("save_at_button").disabled = true;
 	}
 	
</script>